<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Carmezin-Project</title>
<link rel="shortcut icon" href="images/favicon.ico" />

<link href="<?php echo $this->baseUrl();?>/css/stylesheet.css"
	type="text/css" rel="stylesheet" media="all" />
<link href="<?php echo $this->baseUrl();?>/css/jquery.selectbox.css"
    type="text/css" rel="stylesheet" media="all" />
<!--[if lte IE 7]>
 <link rel="stylesheet" type="text/css" href="css/ie7-.css" />
<![endif]-->

<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/jquery.js""></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/cep.js"></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/home.js"></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/mascaras.js"></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/jquery-ui-1.10.1.custom.min.js"></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/form-to-html5.js"></script>
<script type="text/javascript"
	src="<?php echo $this->baseUrl();?>/js/jquery.selectbox-0.2.min.js"></script>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

<div id="fb-root"></div>
<script>(function(d, s, id) {
			  var js, fjs = d.getElementsByTagName(s)[0];
			  if (d.getElementById(id)) return;
			  js = d.createElement(s); js.id = id;
			  js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1&appId=389930231114336";
			  fjs.parentNode.insertBefore(js, fjs);
			}(document, 'script', 'facebook-jssdk'));</script>

<script type="text/javascript">

var popupOpenned = null;

$(document).ready(function(){
	if( $.browser.msie ){
		if( $.browser.version == 7.0 || $.browser.version == 8.0 ){
			 $('body *').each(function(){
				 $('.prod-div:nth-child(4n)').addClass('nthfourth');
			   })
		}
	}

    $('#order, #itens').selectbox({ effect: "fade"});
});

$(document).keyup(function(e) {
	if (e.keyCode == 27) { 
		closeOnEsc();
	}   
});

/** FUNÇÃO ABRE POPUP **/
function openPopup(id) {

	$('html, body').scrollTop(0);
	
	id = $(id).attr('id');

	if(id == 'carrinho'){
		showCart('/cart/show-cart', 'list-carrinho');
		$('.popup-carrinho-title').html('<h1>Carrinho de Compras</h1>');
	}

	if(id == 'edit'){
		showEdit('/client/edit', 'form-edit');
	}
	
	if(!popupOpenned) {
		popupOpenned = id;
		$('#mask').fadeIn(500, function(){
			document.body.style.overflow='hidden';
			$('#popup-'+popupOpenned).fadeIn(1000, function(){
		});	
	});
	} else {
		closePopup(id);
	}
}

function closeOnEsc(){
	$('.popup').fadeOut(500, function(){
		window.location.href="/products";
		$('#mask').fadeOut(500);
		document.body.style.overflow='auto';
	});
}

/** FECHA POPUP **/
function closePopup(popup) {
	if(popup) {
	$('#popup-'+popupOpenned).fadeOut(500, function(){
		popupOpenned = popup;
		$('#mask').fadeIn(500, function(){
			document.body.style.overflow='hidden';
			$('#popup-'+popupOpenned).fadeIn(1000, function(){
			});	
		});	
	});
	} else {
		$('#popup-'+popupOpenned).fadeOut(500, function(){
			window.location.href="/products";
			popupOpenned = popup;
			$('#mask').fadeOut(500);
			document.body.style.overflow='auto';
		});
	}
}
</script>

</head>
<body>
	<!-- MASCARA FUNDO -->
	<div id="mask">
		<!-- POPUPS -->
		<!-- LOGIN  -->
		<div class="popup" id="popup-login">
			<div class="position-close-button">
				<a href="#" class="close-button" onclick="closePopup(null)"></a>
			</div>
			<div class="popup-login-title">
				<h1>Formulário de Login</h1>
			</div>
			<div class="info-login">
				<p>Para começar as compras em nosso site basta logar-se.</p>
				<p>
					Se você não possui um cadastro <a href="#" id="cadastro"
						onclick="openPopup(client)">clique aqui</a> é rápido e prático.
				</p>
			</div>
			<div class="form-login">
				<label><?php echo $this->authErrorMessage?> </label>
				<form action="../auth/login" method="post" id="form-login">
					<input type="text" name="username" placeholder="Login"
						value="<?php echo $this->login?>"><br /> <input type="password"
						name="password" placeholder="Password"><br /> <input type="submit"
						id="login" value="Login"> <input type="reset" value="Limpar">
				</form>
			</div>
		</div>

		<!-- ALTERAR SENHA  -->
		<div class="popup" id="popup-change">
			<div class="position-close-button">
				<a href="#" class="close-button" onclick="closePopup(null)"></a>
			</div>
			<div class="popup-login-title">
				<h1>Alterar Senha</h1>
			</div>
			<div class="change" style="height: 210px; width: 100%; text-align: right;">
				<form action="../client/change-pass" method="post">
					<div>
						Senha antiga:<input placeholder="<?php if(isset($this->changeErrors['old']))echo $this->changeErrors['old']?>" style="margin-left: 2px; margin-bottom: 15px; width: 240px !important;" type="password" name="oldPass" id="oldPass"/>
					</div>
					<div>
						Nova senha:<input placeholder="<?php if(isset($this->changeErrors['new']))echo $this->changeErrors['new']?>" style="margin-left: 2px; margin-bottom: 15px; width: 240px !important;" type="password" name="newPass" id="newPass" />
					</div>
					<div>
						Confirmar senha:<input placeholder="<?php if(isset($this->changeErrors['confirm']))echo $this->changeErrors['confirm']?>" style="margin-left: 2px; margin-bottom: 15px; width: 240px !important;" type="password" name="confirmPass" id="confirmPass" />
					</div>
					<div style="margin-top: 55px; float: right;">
						<input type="submit" value="Alterar">
					</div>
				</form>
			</div>
		</div>
		<!-- CADASTRO  -->
		<div class="popup" id="popup-client"
			style="height: 510px !important; margin-top: 60px !important; width: 970px;">
			<div class="position-close-button">
				<a href="#" class="close-button" onclick="closePopup(null)"></a>
			</div>
			<div class="popup-client-title">
				<h1>Formulário de Cadastro</h1>
			</div>
			<div class="info-cadastro"></div>
			<div class="form-cadastro">
			<?php require_once '../public/htmls/form-login.phtml';?>
			</div>
		</div>

		<!-- CONTATO -->
		<div class="popup" id="popup-contato"
			style="height: 505px !important;">
			<div class="position-close-button">
				<a href="#" class="close-button" onclick="closePopup(null)"></a>
			</div>
			<div class="popup-contato-title">
				<h1>Formulário de Contato</h1>
			</div>
			<div class="form-contato">
			<?php require_once '../application/views/scripts/contact/index.phtml';?>
			</div>
		</div>

		<!-- CARRINHO -->
		<div class="popup" id="popup-carrinho">
			<div class="position-close-button">
				<a href="#" class="close-button" onclick="closePopup(null)"></a>
			</div>
			<div class="popup-carrinho-title"></div>

			<div id="list-carrinho" class="list-carrinho"
				style="height: 430px; width: 915px;">
				<?php require_once '../application/views/scripts/cart/show-cart.phtml';?>
			</div>
		</div>

	</div>
	<div id="container">
	<?php require_once '../public/htmls/header.phtml';?>

		<div id="all">
			<div id="page"></div>
			<div id="bg">
				<div id="content">
				<?php echo $this->layout()->content; ?>
				</div>
			</div>
		</div>

		<?php require_once '../public/htmls/footer.phtml';?>
	</div>

</body>
</html>
